package ui;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.table.DefaultTableCellRenderer;

/**
 * 
 * @author ido
 *
 */
public class BoardTableRenderer  extends DefaultTableCellRenderer {
	

	/**
	 * color the cells with numbers
	 */
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		
		super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

		int	val = Integer.parseInt(value.toString());
		if (val > 0 && val < 10) {
			setBackground(Color.CYAN);
		}
		else {
			setBackground(Color.WHITE);
		}
		setForeground(Color.BLACK);
		setHorizontalAlignment(SwingConstants.CENTER);
		return this;
	}
	
}
